package Java201511;

public class CC {
    String name;
    EE[] arr = new EE[4];
    int i = 0;

    public CC() {
    }

    public CC(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "CC{" +
                "name='" + name + '\'' +
                '}';
    }

    public void add(EE ee) {
        arr[i] = ee;
        i++;

    }

    //重载   多态。
    public void add(String name, int age, int money) {
        arr[i] = new EE(name, age, money);
        i++;
    }

    public void printAll() {
        for (EE ee : arr) {
            System.out.println(ee);
        }
    }

    public EE m1() {
        EE x = arr[0];
        for (EE e : arr) {
            if (e.getAge() > x.getAge()) {
                x = e;
            }
        }
        return x;
    }

    public EE m2() {
        EE x = arr[0];
        for (EE e : arr) {
            if (e.getMoney() < x.getMoney()) {
                x = e;
            }
        }
        return x;
    }

    public EE m3(String 李四) {
        EE x = null;


        for (EE e : arr) {
            if (e.getName() == "李四")
                x = e;
        }
        return x;

    }

    public double m4() {
        double sum = 0;
        for (EE e : arr) {
            sum += e.getMoney();

        }
        double avg = sum / arr.length;

        return avg;
    }
}

